import { Component, macro } from 'cc';
import { Academy } from './Academy';

export class AcademyFixedUpdateStepper extends Component {
	dt: number = 0.04;

	protected start(): void {
		this.schedule(this.updateFixed, this.dt, macro.REPEAT_FOREVER, 2);
	}

	protected updateFixed(dt: number): void {
		if (!Academy.isInitialized || !Academy.instance.isStepperOwner(this)) {
			this.node.destroy();
		} else {
			Academy.instance.environmentStep();
		}
	}
}
